﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace PC.PickleJar.Trello.Data.Resources
{
	internal abstract class ResourceBase<T>
	{
		private System.Uri baseUri;
		private System.Collections.Specialized.NameValueCollection query;

		public ResourceBase(String developerApiKey, String userToken)
		{
			this.baseUri = new Uri("https://api.trello.com/1/");

			this.query = HttpUtility.ParseQueryString(String.Empty);
			this.query.Add("key", developerApiKey);
			this.query.Add("token", userToken);
		}

		public Uri CompleteUri
		{
			get
			{
				UriBuilder builder = new UriBuilder(Path.Combine(this.baseUri.AbsoluteUri, this.RelativeUri.ToString()));
				builder.Query = this.query.ToString();

				return builder.Uri;
			}
		}

		public abstract String RelativeUri
		{
			get;
		}
	}
}
